package com.example.Words.room.model.Dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.Words.room.model.entity.Word;

import java.util.List;

/**
 * <pre>
 *  author:huletian
 *  time    :2020/2/22
 *  desc    :数据库操作
 *  version:1.0
 * </pre>
 */

@Dao //database acess object
public interface WordDao {
    @Insert
    void insertWords(Word... words);

    @Update
    void updateWords(Word... words);

    @Delete
    void deleteWords(Word... words);

    @Query("DELETE from word")
    void deleteAllWords();

    @Query("select * from  word ORDER BY id desc")
    LiveData<List<Word>> getAllwords();

    @Query("select * from word where english_word like :patten order by id desc")
    LiveData<List<Word>> findWordWithPatten(String patten);
}

